﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using GameStateManagement.GameHelper;

namespace _0812367_0912581
{
    class OtherScreen: MyGameScreen
    {
        //Texture2D image;

        //public OtherScreen(Game game, SpriteBatch theSpriteBatch, Texture2D theImage)
        //    : base(game, theSpriteBatch)
        //{
        //    this.image = theImage;
        //}

        //public override void Update(GameTime gameTime)
        //{
        //    base.Update(gameTime);
        //}

        //public override void Draw(GameTime gameTime)
        //{
        //    this.spriteBatch.Draw(this.image, new Rectangle((Game1.Width - this.image.Width) / 2, (Game1.Height - this.image.Height) / 2, this.image.Width, this.image.Height), Color.White);
        //    base.Draw(gameTime);
        //}
        MenuComponent menuComponent;
        Texture2D image;
        Rectangle imageRectangle;
        public string Text { get; set; }
        KeyboardState keyState;
        private SpriteFont Font;
        private Vector2 position;
        public enum GAMESTATE
        {
            OK
        };

        public int SelectedIndex
        {
            get { return menuComponent.SelectedIndex; }
            set { menuComponent.SelectedIndex = value; }
        }

        public OtherScreen(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont, Texture2D image)
            : base(game, spriteBatch)
        {
            string[] menuItems = { "OK" };
            menuComponent = new MenuComponent(game, spriteBatch, spriteFont, menuItems);

            Components.Add(menuComponent);
            this.image = image;
            //imageRectangle = new Rectangle(
            //    (Game.Window.ClientBounds.Width - this.image.Width) / 2,
            //    (Game.Window.ClientBounds.Height - this.image.Height) / 2,
            //    this.image.Width,
            //    this.image.Height);
            //menuComponent.Position = new Vector2((Game.Window.ClientBounds.Width - menuComponent.Width) / 2, imageRectangle.Bottom - menuComponent.Height - 10);

            imageRectangle = new Rectangle(0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height);               
            menuComponent.Position = new Vector2((Game.Window.ClientBounds.Width - menuComponent.Width) / 2, imageRectangle.Bottom - menuComponent.Height - 10);

            //menuComponent.Position = new Vector2(
            //    Game.Window.ClientBounds.Width /2,
            //    imageRectangle.Bottom - menuComponent.Height - 10);
        }
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        protected override void LoadContent()
        {
            Font = GameSettings.Instance.ScreenManager.Game.Content.Load<SpriteFont>("Tip");
            Viewport viewport = GameSettings.Instance.ScreenManager.GraphicsDevice.Viewport;
            position = new Vector2(viewport.X + 20, viewport.Y + viewport.Height - 30);
           
            base.LoadContent();
        }

        public override void Draw(GameTime gameTime)
        {

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
            spriteBatch.Draw(image, imageRectangle, Color.White);
            if (!String.IsNullOrEmpty(this.Text))
                spriteBatch.DrawString(Font, Text, position, Color.White);
            spriteBatch.End();
            base.Draw(gameTime);
        }

    }
}
